﻿using Common.Communal;
using ERP.Domain.Warehouse;
using MediatR;
using Warehouse.API.APP.Commands;
using Warehouse.Services.IServices;

namespace Warehouse.API.APP.Handers
{
    public class InventoryTransactionAddHanders : IRequestHandler<InventoryTransactionAdd, ApiResult<int>>
    {
        IInventoryTransactionService inventoryTransactionService;

        public InventoryTransactionAddHanders(IInventoryTransactionService inventoryTransactionService)
        {
            this.inventoryTransactionService = inventoryTransactionService;
        }

        public async Task<ApiResult<int>> Handle(InventoryTransactionAdd request, CancellationToken cancellationToken)
        {
            var list = request.MapTo<InventoryTransaction>();
            return await inventoryTransactionService.InventoryTransactionAdd(list);
        }
    }
}
